/*
 * Package il.ac.biu.cs.grossmm.cpp
 * File SubscriptionResponse.java
 * 
 * This is a part of presence service framework API. 
 * See javadoc for more information.
 *  
 * Copyright (C) 2006 Grossmann Mark
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package il.ac.biu.cs.grossmm.api.cpp;

/**
 * State of the subscription. This state consist of the subsciption status
 * (success or failure) and the remaining duration, in seconds.
 */
public class State {
	private final boolean isSuccess;

	private final int duration;

	/**
	 * Creates a nde state object.
	 * 
	 * @param status
	 *            status of the subscription
	 * @param duration
	 *            duration of the subscription
	 */
	public State(final boolean isSuccess, final int duration)
	{
		super();
		this.isSuccess = isSuccess;
		this.duration = duration;
	}

	/**
	 * Gets duration of the subscription
	 * 
	 * @return remainig duration of the subscription
	 */
	public int getDuration()
	{
		return duration;
	}

	/**
	 * Queries whether subscription status is a success
	 * 
	 * @return true if subscription status is a success, otherwise returns false
	 */
	public boolean isSuccess()
	{
		return isSuccess;
	}
	
	@Override
	public String toString()
	{
		if( isSuccess )
			return "Success-"+duration;
		else
			return "Failure"; 
			
	}
}
